package cn.jinjimi.app;

import android.test.AndroidTestCase;

import cn.jinjimi.app.store.entity.ArticleEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Hiro on 15/8/5.
 */
public class LocalStoreTest extends AndroidTestCase {

//    private final LocalStore mLocalStore;

    private final static ArticleEntity M_ARTICLE_ENTITY_MOCK;
    private final static String mArticle_id = "111111111111111";

    static {
        M_ARTICLE_ENTITY_MOCK = new ArticleEntity();
        M_ARTICLE_ENTITY_MOCK.setAuthor("frank");
        M_ARTICLE_ENTITY_MOCK.setAuthorId(123456789);
        M_ARTICLE_ENTITY_MOCK.setBaseUrl("http://reader.jinjimi.com/");
        M_ARTICLE_ENTITY_MOCK.setId(mArticle_id);
        M_ARTICLE_ENTITY_MOCK.setReadStatus(1);
    }

    public LocalStoreTest(){
//        mLocalStore = LocalStore.getInstance();

    }

    @Override
    public void setUp() throws Exception{
        super.setUp();

    }

    public void testSaveArticleLocal(){
//        mLocalStore.saveArticleLocal(M_ARTICLE_ENTITY_MOCK);
        List<String> ids = new ArrayList<String>();
        ids.add(mArticle_id);
        List<ArticleEntity> articleEntities = null;//mLocalStore.findArticleByIdsLocal(ids);
        assertNotNull(articleEntities);
        assertEquals(articleEntities.size(), 1);
    }

    public void testSaveArticleLocalWidthDirtyData(){
//        mLocalStore.saveArticleLocal(null);
    }

    public void testSaveArticleLocalTwice(){
//        mLocalStore.saveArticleLocal(M_ARTICLE_ENTITY_MOCK);
        M_ARTICLE_ENTITY_MOCK.setReadStatus(0);
//        mLocalStore.saveArticleLocal(M_ARTICLE_ENTITY_MOCK);

        List<String> ids = new ArrayList<String>();
        ids.add(mArticle_id);
        List<ArticleEntity> articleEntities = null;//mLocalStore.findArticleByIdsLocal(ids);
        assertNotNull(articleEntities);
        assertEquals(articleEntities.size(), 1);
        assertEquals(articleEntities.get(0).getReadtatus(),0);
    }
}
